<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./template/StakeholderTemplate.xhtml">
    <ui:define name="begin">
        <f:view beforePhase="#{grouponManagerBean.initGrouponApplicationList}"></f:view>
    </ui:define>
    <ui:define name="contentInsert">   
        <h:body>
            <h:form id="formMain">
                <h1>View All Offered Groupons</h1>         

                <p:panel header="View All Offered Groupons">
                    <p:accordionPanel autoHeight="false">
                        <p:tab title="Pending Applications">
                            <p:dataTable var="pendingApplication" value="#{grouponManagerBean.pendingGrouponApplicationList}" paginator="true" 
                                         rows="10" emptyMessage="No pending application" selection="#{grouponManagerBean.selectedGrouponApplication}" 
                                         selectionMode="single" rowSelectListener="#{grouponManagerBean.onRowStakeholderSelectNavigateGrouponApplication}"
                                         dblClickSelect="true">

                                <p:column sortBy="#{pendingApplication.id}" filterBy="#{pendingApplication.id}">
                                    <f:facet name="header">
                                        <h:outputText value="ID" />
                                    </f:facet>
                                    <h:outputText value="#{pendingApplication.id}" />
                                </p:column>
                                
                                <p:column sortBy="#{pendingApplication.name}" filterBy="#{pendingApplication.name}">
                                    <f:facet name="header">
                                        <h:outputText value="Name" />
                                    </f:facet>
                                    <h:outputText value="#{pendingApplication.name}" />
                                </p:column>
                                
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Image" />
                                    </f:facet>
                                    <p:graphicImage id="imageDisplay" value="/images/groupons/#{pendingApplication.imageURL}"
                                        height="50" width="50"/> 
                                </p:column>
                                
                                <p:column sortBy="#{pendingApplication.description}" filterBy="#{pendingApplication.description}">
                                    <f:facet name="header">
                                        <h:outputText value="Description" />
                                    </f:facet>
                                    <h:outputText value="#{pendingApplication.description}" />
                                </p:column>
                                
                                <p:column sortBy="#{pendingApplication.offeredPrice}" filterBy="#{pendingApplication.offeredPrice}">
                                    <f:facet name="header">
                                        <h:outputText value="Offered Price" />
                                    </f:facet>
                                    <h:outputText value="#{pendingApplication.offeredPrice}" />
                                </p:column>
                                
                                <p:column sortBy="#{pendingApplication.numberOfIssues}" filterBy="#{pendingApplication.numberOfIssues}">
                                    <f:facet name="header">
                                        <h:outputText value="Quantity" />
                                    </f:facet>
                                    <h:outputText value="#{pendingApplication.numberOfIssues}" />
                                </p:column>
                                
                                <p:column sortBy="#{pendingApplication.startDate}" filterBy="#{pendingApplication.startDate}">
                                    <f:facet name="header">
                                        <h:outputText value="Start Date" />
                                    </f:facet>
                                    <h:outputText value="#{pendingApplication.startDate}" />
                                </p:column>
                                
                                <p:column sortBy="#{pendingApplication.endDate}" filterBy="#{pendingApplication.endDate}">
                                    <f:facet name="header">
                                        <h:outputText value="End Date" />
                                    </f:facet>
                                    <h:outputText value="#{pendingApplication.endDate}" />
                                </p:column>
                                
                                <p:column sortBy="#{pendingApplication.status}" filterBy="#{pendingApplication.status}">
                                    <f:facet name="header">
                                        <h:outputText value="Status" />
                                    </f:facet>
                                    <h:outputText value="#{pendingApplication.status}" />
                                </p:column>
                                
                            </p:dataTable>
                        </p:tab>
                        <p:tab title="All groupon applications">
                            <p:dataTable var="grouponApplication" value="#{grouponManagerBean.grouponApplicationList}" paginator="true" 
                                         rows="10" emptyMessage="No application" selection="#{grouponManagerBean.selectedGrouponApplication}" 
                                         selectionMode="single" rowSelectListener="#{grouponManagerBean.onRowStakeholderSelectNavigateGrouponApplication}"
                                         dblClickSelect="true">

                                <p:column sortBy="#{grouponApplication.id}" filterBy="#{grouponApplication.id}">
                                    <f:facet name="header">
                                        <h:outputText value="ID" />
                                    </f:facet>
                                    <h:outputText value="#{grouponApplication.id}" />
                                </p:column>
                                
                                <p:column sortBy="#{grouponApplication.name}" filterBy="#{grouponApplication.name}">
                                    <f:facet name="header">
                                        <h:outputText value="Name" />
                                    </f:facet>
                                    <h:outputText value="#{grouponApplication.name}" />
                                </p:column>
                                                         
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Image" />
                                    </f:facet>
                                    <p:graphicImage id="imageDisplay" value="/images/groupons/#{grouponApplication.imageURL}"
                                        height="50" width="50"/> 
                                </p:column>
                               
                                
                                <p:column sortBy="#{grouponApplication.description}" filterBy="#{grouponApplication.description}">
                                    <f:facet name="header">
                                        <h:outputText value="Description" />
                                    </f:facet>
                                    <h:outputText value="#{grouponApplication.description}" />
                                </p:column>
                                
                                <p:column sortBy="#{grouponApplication.offeredPrice}" filterBy="#{grouponApplication.offeredPrice}">
                                    <f:facet name="header">
                                        <h:outputText value="Offered Price" />
                                    </f:facet>
                                    <h:outputText value="#{grouponApplication.offeredPrice}" />
                                </p:column>
                                
                                <p:column sortBy="#{grouponApplication.numberOfIssues}" filterBy="#{grouponApplication.numberOfIssues}">
                                    <f:facet name="header">
                                        <h:outputText value="Quantity" />
                                    </f:facet>
                                    <h:outputText value="#{grouponApplication.numberOfIssues}" />
                                </p:column>
                                
                                <p:column sortBy="#{grouponApplication.startDate}" filterBy="#{grouponApplication.startDate}">
                                    <f:facet name="header">
                                        <h:outputText value="Start Date" />
                                    </f:facet>
                                    <h:outputText value="#{grouponApplication.startDate}" />
                                </p:column>
                                
                                <p:column sortBy="#{grouponApplication.endDate}" filterBy="#{grouponApplication.endDate}">
                                    <f:facet name="header">
                                        <h:outputText value="End Date" />
                                    </f:facet>
                                    <h:outputText value="#{grouponApplication.endDate}" />
                                </p:column>
                                
                                <p:column sortBy="#{grouponApplication.status}" filterBy="#{grouponApplication.status}">
                                    <f:facet name="header">
                                        <h:outputText value="Status" />
                                    </f:facet>
                                    <h:outputText value="#{grouponApplication.status}" />
                                </p:column>
                            </p:dataTable>
                        </p:tab> 
                    </p:accordionPanel> 
                </p:panel>
            </h:form>
        </h:body>
    </ui:define>
</ui:composition>
